#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;


class Solution {
public:
    int lengthOfLastWord(string s) {
        int len = s.size();
        bool lastSpace = true;
        int ix = len-1;
        int ans = 0;
        while(ix >= 0 && s[ix] == ' '){
            ix--;
        }

        while(ix >= 0 && s[ix] != ' '){
            ans++;
            ix--;
        }
        return ans;
    }
};


int main(){
    Solution solution;
    vector<vector<int>> input = {{1,3},{2,6},{8,10},{15,18}};
    // solution.maxSubArray(input);
    solution.lengthOfLastWord("Hello World");
    return 0;
}
